<template>
  <component
    :is="componentName"
    v-bind="$attrs"
    v-on="$listeners"
    @after-save="afterSave"
    :is-physical-product="isPhysicalProduct"
  >
    <slot></slot>
  </component>
</template>

<script>
import { firstUpperCase } from '@/utils'
export default {
  name: 'DetailContainer',
  components: {
    ProductDetail: () =>
      import('@/views/product/productConfig/components/Detail/index.vue'), // 产品上架 processType === 1
    CustomerDetail: () =>
      import('@/views/customer/customerList/components/detail/index'), // 客户详情
    SaleDetail: () => import('@/views/saleOrder/saleOrderList/Detail/index'), // 销售单详情
    ReceivableDetail: () =>
      import('@/views/financial/receivableList/components/detail/index'), // 回款录入审批
    ReturnDetail: () =>
      import('@/views/saleOrder/saleOrderList/Detail/ReturnDetail/index'), // 退款详情
    SpecialPriceDetail: () =>
    import('@/views/product/productSpecialPrice/components/Detail/index') // 特殊价格配置详情
  },
  props: {
    type: {
      type: String,
      default: 'Product'
    },
    isPhysicalProduct: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {}
  },
  computed: {
    componentName () {
      return `${firstUpperCase(this.type)}Detail`
    }
  },
  watch: {},
  created () {
  },
  methods: {
    afterSave () {
      this.$emit('after-save')
    }
  }
}
</script>
